﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;

namespace Com.CMS263.DAO
{
    public class PeixunDAO : BaseService
    {
        public PeixunDAO() { }
        public int GetMaxId()
        {
            string hql = "from Peixun order by Id desc";
            try
            {
                Peixun prod = FindList<Peixun>(hql, null, 0, 1).First();
                return prod.Id + 1;
            }
            catch (Exception)
            {

                return 1;
            }
        }
        public IList<Peixun> GetListByPager(int page, int pagesize)
        {
            string hql = " from Peixun where 1=1";
            
            hql += " order by AddDate Desc";
            try
            {
                if (page == -1)
                {
                    return FindList<Peixun>(hql, null, null, null);
                }
                else
                {
                    return FindList<Peixun>(hql, null, (page - 1) * pagesize, pagesize);
                }
            }
            catch (Exception)
            {

                return null;
            }

        }

        public int GetListByPager()
        {
            string hql = "select count(*) from Peixun where 1=1";
           
            try
            {
                return Convert.ToInt32(GetValue(hql));
            }
            catch (Exception)
            {
                return 0;
            }

        }
    }
}
